
module.exports = function (plop) {
    plop.setGenerator('model', {
        description: '创建model',
        prompts: [
            {
                type: 'input',
                name: 'name',
                message: '请输入model名称',
            },
        ],
        actions: () => {
            const pathCaseName = '{{ pathCase name }}'    // change/format/to/this
            const properCaseName = '{{ properCase name }}'// ChangeFormatToThis
            const camelCaseName = '{{ camelCase name }}'  // changeFormatToThis
            const snakeCaseName = '{{ snakeCase name }}'  // change_format_to_this
            const dashCaseName = '{{dashCase name}}'      // change-format-to-this
            const today = new Date().toISOString().split('T')[0]   // current date, format: 2022-08-17
            const serialVersionUID = Math.floor(Math.random() * 10000000000) + 1

            return [
                {
                    type: 'add',
                    path: `oj-core/src/main/java/top/hcode/hoj/pojo/entity/${properCaseName}.java`,
                    templateFile: 'plop-templates/model.hbs',
                    data: {
                        today, serialVersionUID
                    }
                },
                {
                    type: 'add',
                    path: `oj-web/src/main/java/top/hcode/hoj/mapper/${properCaseName}Mapper.java`,
                    templateFile: 'plop-templates/mapper.hbs',
                    data : {today},
                },
                {
                    type: 'add',
                    path: `oj-web/src/main/java/top/hcode/hoj/dao/${properCaseName}Dao.java`,
                    templateFile: 'plop-templates/dao.hbs',
                    data : {today},
                },
                {
                    type: 'add',
                    path: `oj-web/src/main/java/top/hcode/hoj/service/admin/Admin${properCaseName}Service.java`,
                    templateFile: 'plop-templates/admin-service.hbs',
                    data : {today},
                },
                {
                    type: 'add',
                    path: `oj-web/src/main/java/top/hcode/hoj/controller/admin/Admin${properCaseName}Controller.java`,
                    templateFile: 'plop-templates/admin-controller.hbs',
                    data : {today},
                },
                // {
                //     type: 'add',
                //     path: `meter-web/src/main/java/cn/cytong/meter/service/${properCaseName}Service.java`,
                //     templateFile: 'plop-templates/service.hbs',
                // },
                // {
                //     type: 'add',
                //     path: `meter-web/src/main/java/cn/cytong/meter/controller/${properCaseName}Controller.java`,
                //     templateFile: 'plop-templates/controller.hbs',
                // },
            ]
        },
    });
};